import http from '@/utils/request'
// 获取所有角色列表
export const reqGetRolesList = (queryInfo) => {
  return http({
    method: 'get',
    url: '/sys/role',
    params: queryInfo
  })
}

// 删除角色
export const reqDelRoleById = id => {
  return http({
    method: 'delete',
    url: `/sys/role/${id}`
  })
}

// 新增角色
export const reqAddRole = data => {
  return http({
    method: 'post',
    url: '/sys/role',
    data
  })
}

// 根据id查询角色信息
export const reqGetRoleById = id => {
  return http({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

// 更新角色信息
export const reqUpdateRole = data => {
  return http({
    method: 'put',
    url: `/sys/role/${data.id}`,
    data
  })
}

// 获取公司信息的接口
export const reqGetCompanyInfoById = id => {
  return http({
    method: 'get',
    url: `/company/${id}`
  })
}

// 为角色分配权限
export const reqSetRights = (id, permIds) => {
  return http({
    method: 'put',
    url: '/sys/role/assignPrem',
    data: {
      id, // 角色id
      permIds // 权限列表的集合  数组包字符串
    }
  })
}
